﻿
#include <iostream>
#include <malloc.h>
using namespace std;
#include <string.h>

/* 常量 */
#define MAX 3

/* 函数声明 */
void swapAddressByPoint(int *a, int *b);


int main(){
	int a = 1;
	int b =2;
	swapAddressByPoint(&a, &b);
	cout << "\n\t'a':" << a << "\t'b'" << b << endl;
}


void swapAddressByPoint(int *a, int *b){
	int *temp = (int*)malloc(sizeof(int));
	cout << "initialize malloc address for 'temp' (which) is:" << temp << "\n";
	temp = a;
	cout << "swap from variable 'a' point, now address for 'temp' (which) is:" << temp << "\n";
	a = b;
	b = temp;
	cout << "swap address both 'a' point and 'b' point, now address for 'a' is:" << a << "\tand 'b' is" << b << endl;
} 
